package com.sc.nft.controller;

import com.sc.nft.controller.request.IdRequest;
import com.sc.nft.entity.vo.ArticleDetailsVO;
import com.sc.nft.entity.vo.DaoSchoolTopHomeArticleListVO;
import com.sc.nft.service.DaoSchoolArticleService;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 文章表(DaoSchoolArticle)表控制层
 *
 * @author makejava
 * @since 2023-03-13 16:20:49
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("daoSchoolArticle")
@Api(tags = "文章列表")
public class DaoSchoolArticleController {

    /**
     * 服务对象
     */
    private final DaoSchoolArticleService daoSchoolArticleService;

    @ApiOperation(value = "获取置顶的文章", notes = "获取首页父集列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/getHomeTopArticle", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<List<DaoSchoolTopHomeArticleListVO>> getHomeTopArticle() {
        return Result.success(daoSchoolArticleService.getHomeTopArticle());
    }

    @ApiOperation(value = "通过id获取文章", notes = "通过id获取文章", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/byIdGetArticle", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<ArticleDetailsVO> byIdGetArticle(@RequestBody IdRequest idRequest) {
        return Result.success(daoSchoolArticleService.byIdGetArticle(idRequest.getId()));
    }

}
